//
//  ViewController.swift
//  oschina
//
//  Created by 林村 on 15/5/8.
//  Copyright (c) 2015年 林村. All rights reserved.
//

import UIKit

//import ViewPagerController

class NewsPagerViewController: ViewPagerController , ViewPagerDataSource , ViewPagerDelegate {

    let newsTabs:[String] = ["最新资讯","最新博客","推荐阅读"]
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        
        //var manager = AFHTTPRequestOperationManager();
        
        self.dataSource = self;
        self.delegate = self;
        
        // 设置状态栏背景色为绿色，文字为白色
        navigationController?.navigationBar.barTintColor = UIColor(hexString: Colors.mainGreen)
        UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: true)

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    
    
    func numberOfTabsForViewPager(viewPager: ViewPagerController!) -> UInt {
        return UInt(newsTabs.count)
    }
    
    func viewPager(viewPager: ViewPagerController!, viewForTabAtIndex index: UInt) -> UIView! {
        var label = UILabel()
        
        label.text = newsTabs[Int(index)]
        label.textColor = UIColor.whiteColor()
        label.font = UIFont(name: label.font.fontName, size: 13)
        //label.backgroundColor = UIColor(hexString: Colors.mainGreen)
        label.sizeToFit()
    
        return label
    }
    
    func viewPager(viewPager: ViewPagerController!, contentViewControllerForTabAtIndex index: UInt) -> UIViewController! {
        var cvc: AnyObject? = self.storyboard?.instantiateViewControllerWithIdentifier("baseListController")
        var con = cvc as! UIViewController
        return con
    }
    
    // TAB背景色设置成绿色
    func viewPager(viewPager: ViewPagerController!, colorForComponent component: ViewPagerComponent, withDefault color: UIColor!) -> UIColor! {
        switch component {
        case ViewPagerComponent.TabsView:
            return UIColor(hexString: Colors.mainGreen)
        case ViewPagerComponent.Indicator:
            return UIColor.whiteColor()
        default :
            return color
        }
    }
    
    func viewPager(viewPager: ViewPagerController!, valueForOption option: ViewPagerOption, withDefault value: CGFloat) -> CGFloat {
        switch option {
        case ViewPagerOption.TabHeight:
            return CGFloat(35)
        default:
            return value;
        }
    }
    
}

